<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <th:block th:include="include :: header('新增工作安排')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>

<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-arrange-add">
            <h4 class="form-header h4">添加工作安排</h4>
            <input id="userIds" name="userIds" class="form-control" type="hidden">
            <input id="status" name="status" class="form-control" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">填报表单：</label>
                <div class="col-sm-8">
                    <select name="templateId" class="form-control select2" required>
                        <option th:each="dict : ${templates}" th:text="${dict.templateName}"
                            th:value="${dict.templateId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">工作分类：</label>
                <div class="col-sm-8">
                    <select name="workCategory" class="form-control noselect2"
                        th:with="type=${@dict.getType('work_category')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">工作标题：</label>
                <div class="col-sm-8">
                    <input name="arrangeTitle" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">发布范围：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <span class="input-group-addon"><a onclick="javaScript:chooseAllUser();">全员</a></span>
                        <span class="input-group-addon"><a onclick="javaScript:chooseUser();">选择</a></span>
                        <input id="releaseScope" name="releaseScope" class="form-control" type="text" required>
                        <span class="input-group-addon"><a onclick="javaScript:clearUser();">清空</a></span>
                    </div>

                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">参与人数：</label>
                <div class="col-sm-8">
                    <input id="total" name="total" class="form-control" type="number" unselectable="on" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startDate" class="form-control" placeholder="格式：yyyy-MM-dd" type="text"
                            th:value="*{today}">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">结束日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endDate" class="form-control" placeholder="格式：yyyy-MM-dd" type="text"
                            th:value="*{today}">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">预警日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="warningDate" class="form-control" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">平台提示：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('is_tips')}">
                        <input type="radio" th:id="${'websiteTips_' + dict.dictCode}" name="websiteTips"
                            th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'websiteTips_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">短信提示：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('is_tips')}">
                        <input type="radio" th:id="${'smsTips_' + dict.dictCode}" name="smsTips"
                            th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'smsTips_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
        </form>
        <div class="row">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-success" onclick="submitHandler('1')"><i class="fa fa-plus"></i>暂 存</button>&nbsp;
                <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler('2')"><i class="fa fa-check"></i>发 布</button>&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭</button>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "work/arrange"
        $("#form-arrange-add").validate({
            focusCleanup: true
        });

        function submitHandler(status) {
            if ($.validate.form()) {
                $('#status').val(status)
                $.operate.save(prefix + "/add", $('#form-arrange-add').serialize());
            }
        }

        $("input[name='startDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='endDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='warningDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function chooseAllUser() {
            $("#releaseScope").val(page_constants.ALL_USER)
            $.ajax({
                type: "POST",
                url: ctx + "common/activeUserCount",
                error: function (request) {
                    $.modal.alertError("系统错误");
                },
                success: function (data) {
                    $("#total").val(data.data);
                }
            });
        }

        function chooseUser() {
            $.modal.open("选择用户", ctx + "common/chooseUser");
        }

        function clearUser() {
            $("#releaseScope").val("");
            $("#total").val(0);
        }
    </script>
</body>

</html>